package com.wanwu.channel.server.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.wanwu.channel.common.enums.AlarmTypeEnum;
import com.wanwu.channel.core.tool.AlarmPoolUtil;
import com.wanwu.monitor.api.util.AlarmMsgModelUtil;
import com.wanwu.monitor.api.enums.SystemEnum;
import com.wanwu.monitor.api.util.vo.AlarmMsgVo;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * 钉钉告警池测试入口
 * @author chenshunxing
 * @date 2020/08/12 16:42
 */
@RestController
@RequestMapping("/")
public class AlarmPoolTestController {

    @Resource
    private AlarmPoolUtil alarmPoolUtil;

    //测试机器人
    private static final String dingkey1="468d47979a3b1ba2d001df2fbcbc9710e8b9935ba084ae99cb38d0813e5027c7";

    //测试机器人2
    private static final String dingkey2="4c514bc589853d0c072b5c503172772ac470c931ba1a2edd79447ff02f842057";

    @Value("${mq.ding.appKey}")
    private String dingKey;
    /**
     * 给缓冲池中添加告警信息 默认间隔30秒自动发，测试时如果需要立马发：调用alarmPoolUtil.sendAndClear()方法。
     */
    @RequestMapping(value = "addAlarmTest")
    @ResponseBody
    public String addAlarmTest(){

        AlarmMsgVo alarmMsgVo = new AlarmMsgVo.Builder().head("渠道系统告警：【支付宝统一回调】回调状态与本地不一致")
                .field("渠道单号", "[{\"bizType\":\"1\",\"bizOrderNo\":\"PD202008261552164860000000001763\",\"fundType\":\"11\",\"cooperationMode\":\"2\",\"merchantId\":\"SI202006291812149850000000000181\",\"merchantName\":\"寺库跨境(SGM测试-new)\",\"orderAmount\":1222.60,\"settleAmount\":1222.60,\"payChannel\":\"6\",\"settDate\":\"20200826\",\"userId\":\"SystemCall\",\"lastPayTime\":{\"nano\":0,\"dayOfYear\":208,\"dayOfWeek\":\"SUNDAY\",\"month\":\"JULY\",\"dayOfMonth\":26,\"year\":2020,\"monthValue\":7,\"hour\":15,\"minute\":36,\"second\":22,\"chronology\":{\"id\":\"ISO\",\"calendarType\":\"iso8601\"}},\"remark\":\"\",\"accountVo\":{\"accountName\":\"KAIHU\",\"accountNo\":\"6228487879765823418\",\"beneficiaryId\":\"SSS\",\"supplierNo\":\"SI202006291812149850000000000181\"}}]addada").build();
        alarmPoolUtil.addGatherAlarm(dingkey1, AlarmTypeEnum.ALIPAYCOMMONNOTIFYSTATUSDIFF, alarmMsgVo);


        return "success";
    }


}
